package com.bwie.system.controller;

import com.bwie.common.domain.CarInfo;
import com.bwie.common.domain.ChargeStationType;
import com.bwie.common.domain.City;
import com.bwie.common.domain.request.ChargeStationReq;
import com.bwie.common.domain.request.CollectReq;
import com.bwie.common.domain.request.CommentReq;
import com.bwie.common.domain.response.ChargeStationRes;
import com.bwie.common.domain.response.CommentRes;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.system.service.ChargeStationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: ChargeStationController
 * @Description:
 * @Author: ZengFz
 * @Date: 2024/5/17 11:23:16
 */
@RestController
@RequestMapping("/chargeStation")
public class ChargeStationController {

    @Autowired
    private ChargeStationService chargeStationService;

    /**
     * 电站列表的城市展示
     * @return
     */
    @GetMapping("/cityList")
    public Result<List<City>> cityList(){
        return Result.success(chargeStationService.cityList());
    }

    /**
     * 电站列表展示
     * @param chargeStationReq
     * @return
     */
    @PostMapping("/chargeStationList")
    public Result<PageResult<ChargeStationRes>> chargeStationList(@RequestBody ChargeStationReq chargeStationReq){
        return Result.success(chargeStationService.chargeStationList(chargeStationReq));
    }

    /**
     * 将充电类型的数据
     * @return
     */
    @GetMapping("/chargeStationTypeList")
    public Result<List<ChargeStationType>> chargeStationTypeList(){
        return Result.success(chargeStationService.chargeStationTypeList());
    }

    /**
     * 修改 字典 数据
     */
    @PostMapping("/updChargeStationType")
    public Result upd(@RequestBody ChargeStationType chargeStationType){
        chargeStationService.updChargeStationType(chargeStationType);
        return Result.success();
    }

    /**
     * 站点收藏的统计
     */
    @GetMapping("/countStation")
    public Result countStation(){
        Integer stationNum = chargeStationService.countStation();
        return Result.success(stationNum,"当前用户一共收藏了"+stationNum+"站点");
    }

    /**
     * 站点收藏 和 站点取消收藏
     */
    @PostMapping("/updCollect")
    public Result updCollect(@RequestBody CollectReq collectReq){
        chargeStationService.upCollect(collectReq);
        return Result.success();
    }

    /**
     * 查询 印象统计 并展示
     */
    @GetMapping("/commentList")
    public Result<List<CommentRes>> commentList(){
        List<CommentRes> commentList =  chargeStationService.commentList();
        return Result.success(commentList);
    }

    /**
     * 实现站点的评价印象接口
     */
    @PostMapping("/updComment")
    public Result updComment(@RequestBody CommentReq commentReq){
        chargeStationService.updComment(commentReq);
        return Result.success();
    }

    /**
     * 实现充电费用的计算接口
     */
    @PostMapping("/valuation")
    public Result valuation() {
        //TODO 充电费用的计算

        return Result.success();
    }

    /**
     * 用户 新增 车辆信息
     */
    @PostMapping("/userAddCar")
    public Result userAddCar(@RequestBody CarInfo carInfo){
        chargeStationService.userAddCar(carInfo);
        return Result.success();
    }

    /**
     * 用户删除 车辆信息
     */
    @PostMapping("/userDelCar")
    public Result userDelCar(Integer carId){
        chargeStationService.userDelCar(carId);
        return Result.success();
    }
    /**
     * 用户 修改 车辆信息
     */
    @PostMapping("/userUpdCar")
    public Result userUpdCar(@RequestBody CarInfo carInfo){
        chargeStationService.userUpdCar(carInfo);
        return Result.success();
    }

}
